use "../Intermediate/bank_lending_panel", clear

bys BankID: egen total_debt = total(debt)
drop if total_debt == 0

gen grp = strong_policy_new1_max == 1

collapse (sum) loan, by(grp year)

tsset grp year
replace loan    = loan/1e3
tssmooth ma loan_ma = loan, window(2 1)

bys grp: gen base_loan = loan_ma if year == 2010
bys grp: egen baseline = max(base_loan)
gen loan_ma_sc = loan_ma / baseline
label var loan_ma_sc "Coal Aggregate Loan Issuance"
sort grp year
save "../Intermediate/Figure_5", replace

